package org.ala.tiktools.generator.mybatis.creator.entity;

import org.ala.tiktools.generator.mybatis.dbinfo.ColumnInfo;
import org.ala.tiktools.generator.mybatis.tools.FieldType;
import org.ala.tiktools.generator.mybatis.tools.Tools;

/**
 * 字段信息
 *
 * @author ala
 * @date 2024-12-31 12:43
 */
public class FieldInfo {

    protected String name;
    protected String upHumpName;
    protected String columnName;
    protected String get, set;
    protected String type;
    protected Class<?> typeClass;
    protected String desc;
    protected boolean swagger;
    protected boolean onlyAutoIncrementPrimaryKey;

    public static FieldInfo build(ColumnInfo column) {
        FieldInfo field = new FieldInfo();
        //  驼峰命名
        field.name = Tools.hump(column.getName());
        field.upHumpName = Tools.upHump(field.name);
        field.columnName = column.getName();
        FieldType ft = Tools.javaType(column.getType());
        field.type = ft.getTypeName();
        field.typeClass = ft.getTypeClass();
        field.get = Tools.getMethodName(field.name);
        field.set = Tools.setMethodName(field.name);
        field.desc = column.getDesc();
        field.swagger = column.isGenerated();
        field.onlyAutoIncrementPrimaryKey = column.isOnlyAutoIncrementPrimaryKey();
        return field;
    }

    public String getColumnName() {
        return columnName;
    }

    public void setColumnName(String columnName) {
        this.columnName = columnName;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getGet() {
        return get;
    }

    public void setGet(String get) {
        this.get = get;
    }

    public String getSet() {
        return set;
    }

    public void setSet(String set) {
        this.set = set;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    public boolean isSwagger() {
        return swagger;
    }

    public void setSwagger(boolean swagger) {
        this.swagger = swagger;
    }

    public Class<?> getTypeClass() {
        return typeClass;
    }

    public void setTypeClass(Class<?> typeClass) {
        this.typeClass = typeClass;
    }

    public boolean isOnlyAutoIncrementPrimaryKey() {
        return onlyAutoIncrementPrimaryKey;
    }

    public void setOnlyAutoIncrementPrimaryKey(boolean onlyAutoIncrementPrimaryKey) {
        this.onlyAutoIncrementPrimaryKey = onlyAutoIncrementPrimaryKey;
    }

    public String getUpHumpName() {
        return upHumpName;
    }

    public void setUpHumpName(String upHumpName) {
        this.upHumpName = upHumpName;
    }
}
